# import pymysql
# import time
# import datetime

# def create_table() :
#     sql="""create table if not exists MovieType(
#         tid int primary key,
#         tname varchar(20),
#         tcontent varchar(200),
#         tdate datetime
#     )"""
#     conn=pymysql.connect(
#         host="192.168.174.137",
#         user="root",
#         password="root123456",
#         database="test",
#         port=3306,
#         charset="utf8")
#     print("连接数据库成功！")

#     vehicle=conn.cursor()
#     vehicle.execute(sql)
#     print("操作成功！")
    
#     vehicle.close()
#     conn.close()
#     print("关闭数据库成功！")

# def edit_table() :
#     tid=input("请输入id:")
#     tname=input("请输入电影名称:")
#     tcontent=input("请输入电影所属类型:")
#     sql=f"insert into MovieType values({tid},'{tname}','{tcontent}',now())"
#     # sql="""insert into MovieType values(%s,%s,%s,now())"""
#     # data=[(1,'喜剧','这是一个搞笑的电影'),
#     #       (2,'动作','这是一个打斗的电影')]
#     conn=pymysql.connect(
#         host="192.168.174.137",
#         user="root",
#         password="root123456",
#         database="test",
#         port=3306,
#         charset="utf8")
#     print("连接数据库成功！")

#     vehicle=conn.cursor()
#     result=vehicle.execute(sql)
#     # result=vehicle.executemany(sql,data)
#     if result>0 :
#         print("添加成功！")
#     else :
#         print("添加失败！")

#     conn.commit()
    
#     vehicle.close()
#     conn.close()
#     print("关闭数据库成功！")


# def select_table() :
#     sql="select * from MovieType"
#     conn=pymysql.connect(
#         host="192.168.174.137",
#         user="root",
#         password="root123456",
#         database="test",
#         port=3306,
#         charset="utf8")
#     print("连接数据库成功！")

#     vehicle=conn.cursor()
#     vehicle.execute(sql)
#     result=vehicle.fetchall()
#     for i in result :
#         print(i[0],i[1],i[2],datetime.datetime.strftime(i[3],"%Y年%m月%d日"))
    
#     vehicle.close()
#     conn.close()
#     print("关闭数据库成功！")

# if __name__=="__main__" :
#     #create_table()
#     edit_table()
#     #select_table()



